package com.xn.myyxcampus.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import com.xn.myyxcampus.MyApplication;

public class MyPreferences {

	private static SharedPreferences preferences = null;
	private static Editor edit = null;
	private static final String SHARED_FILE_NAME = "TracyShare";

	/** 用户标识符 */
	public static final String TOKEN = "token";

	public static SharedPreferences getShare() {
		if (null == preferences) {
			Context context = MyApplication.getContext();
			preferences = context.getSharedPreferences(SHARED_FILE_NAME,
					context.MODE_PRIVATE);
		}
		return preferences;
	}


	public static String getToken(Context context) {
		String token = MyPreferences.getShare().getString(TOKEN, "");
		return token;
	}

	public static boolean isLoginIn(Context context) {
		if (("".equals(getToken(context))) || (null == getToken(context))
				|| getToken(context).equals(null)) {
			return false;
		}
		return true;
	}
}
